import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '赛事',
    align:"center",
    dataIndex: 'saisId_dictText'
   },
   {
    title: '赛区',
    align:"center",
    dataIndex: 'saiq_dictText'
   },
   {
    title: '赛程',
    align:"center",
    dataIndex: 'saic_dictText'
   },
   {
    title: '标题',
    align:"center",
    dataIndex: 'biaot'
   },
   {
    title: '所属控件',
    align:"center",
    dataIndex: 'suoskj'
   },
   {
    title: '控件类型',
    align:"center",
    dataIndex: 'kongjlx_dictText'
   },
   {
    title: '控件名称',
    align:"center",
    dataIndex: 'kongjmc'
   },
   {
    title: '控件数据',
    align:"center",
    dataIndex: 'kongjsj'
   },
   {
    title: '可见权限',
    align:"center",
    dataIndex: 'kejqx_dictText'
   },
   {
    title: '是否换行',
    align:"center",
    dataIndex: 'shifhh',
    customRender:({text}) => {
       return  render.renderSwitch(text, [{text:'是',value:'Y'},{text:'否',value:'N'}])
     },
   },
   {
    title: '字典表',
    align:"center",
    dataIndex: 'zidb'
   },
   {
    title: '字典编码',
    align:"center",
    dataIndex: 'zidbm'
   },
   {
    title: '字典显示字段',
    align:"center",
    dataIndex: 'zidxszd'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "赛事",
      field: 'saisId',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"cbda_sais,mingc,id"
      },
      //colProps: {span: 6},
 	},
	{
      label: "赛程",
      field: 'saic',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"saisjc"
      },
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '赛事',
    field: 'saisId',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"cbda_sais,mingc,id"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入赛事!'},
          ];
     },
  },
  {
    label: '赛区',
    field: 'saiq',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"saiq"
     },
  },
  {
    label: '赛程',
    field: 'saic',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"saisjc"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入赛程!'},
          ];
     },
  },
  {
    label: '标题',
    field: 'biaot',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入标题!'},
          ];
     },
  },
  {
    label: '所属控件',
    field: 'suoskj',
    defaultValue: "root",
    component: 'Input',
  },
  {
    label: '控件类型',
    field: 'kongjlx',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"kongjlx"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入控件类型!'},
          ];
     },
  },
  {
    label: '控件名称',
    field: 'kongjmc',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入控件名称!'},
          ];
     },
  },
  {
    label: '控件数据',
    field: 'kongjsj',
    component: 'InputTextArea',
  },
  {
    label: '可见权限',
    field: 'kejqx',
    component: 'JSelectMultiple',
    componentProps:{
        dictCode:"sys_role,role_name,id"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入可见权限!'},
          ];
     },
  },
  {
    label: '是否换行',
    field: 'shifhh',
     component: 'JSwitch',
     componentProps:{
     },
  },
  {
    label: '字典表',
    field: 'zidb',
    component: 'Input',
  },
  {
    label: '字典编码',
    field: 'zidbm',
    component: 'Input',
  },
  {
    label: '字典显示字段',
    field: 'zidxszd',
    component: 'Input',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  saisId: {title: '赛事',order: 0,view: 'list', type: 'string',dictTable: "cbda_sais", dictCode: 'id', dictText: 'mingc',},
  saiq: {title: '赛区',order: 1,view: 'list', type: 'string',dictCode: 'saiq',},
  saic: {title: '赛程',order: 2,view: 'list', type: 'string',dictCode: 'saisjc',},
  biaot: {title: '标题',order: 3,view: 'text', type: 'string',},
  suoskj: {title: '所属控件',order: 4,view: 'text', type: 'string',},
  kongjlx: {title: '控件类型',order: 5,view: 'list', type: 'string',dictCode: 'kongjlx',},
  kongjmc: {title: '控件名称',order: 6,view: 'text', type: 'string',},
  kongjsj: {title: '控件数据',order: 7,view: 'textarea', type: 'string',},
  kejqx: {title: '可见权限',order: 8,view: 'list_multi', type: 'string',dictTable: "sys_role", dictCode: 'id', dictText: 'role_name',},
  shifhh: {title: '是否换行',order: 9,view: 'switch', type: 'string',},
  zidb: {title: '字典表',order: 10,view: 'text', type: 'string',},
  zidbm: {title: '字典编码',order: 11,view: 'text', type: 'string',},
  zidxszd: {title: '字典显示字段',order: 12,view: 'text', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}